package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.OtherRobotInfo;
import com.ruoyi.system.domain.RobotWechatUser;
import com.ruoyi.system.mapper.OtherRobotInfoMapper;
import com.ruoyi.system.mapper.RobotWechatUserMapper;
import com.ruoyi.system.service.IOtherRobotInfoService;
import com.ruoyi.system.service.IRobotWechatUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
@DataSource(value = DataSourceType.SLAVE)
public class OtherRobotInfoServiceImpl extends ServiceImpl<OtherRobotInfoMapper, OtherRobotInfo> implements IOtherRobotInfoService {

    @Resource
    private OtherRobotInfoMapper otherRobotInfoMapper;

    @DataSource(value = DataSourceType.SLAVE)
    public List<OtherRobotInfo> selectOtherRobotInfoList() {
        return otherRobotInfoMapper.selectList(new LambdaQueryWrapper<OtherRobotInfo>());
    }


    @DataSource(value = DataSourceType.SLAVE)
    public OtherRobotInfo selectOtherRobotInfo(String wxid) {
        //return otherRobotInfoMapper.selectOne(new LambdaQueryWrapper<OtherRobotInfo>().eq(OtherRobotInfo::getWxid, wxid));
        List<OtherRobotInfo> otherRobotInfos = otherRobotInfoMapper.selectList(new LambdaQueryWrapper<OtherRobotInfo>().eq(OtherRobotInfo::getWxid, wxid));
        if(otherRobotInfos == null || otherRobotInfos.size() == 0) {
            return new OtherRobotInfo();
        }
        return otherRobotInfos.get(0);
    }

    @Override
    public List<OtherRobotInfo> selectOtherRobotInfoBywxids(List<String> wxids) {
        return otherRobotInfoMapper.selectList(new LambdaQueryWrapper<OtherRobotInfo>().in(OtherRobotInfo::getWxid, wxids));
    }

}
